<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        setTimeout(function(){
            console.log('1');
        },1000);//1m后执行

        timer=setInterval(() => {
            console.log('2');
        }, 1000);//每隔1m执行一次
        clearInterval(timer);//清除
    </script>
</body>
</html>